/*
* @Author: chenggh
* @Date: 2025-06-21
* @Link to Problem : https://oj.neu.edu.cn/courses/27/part/224/problem/1011
*/
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> v(n);
	set<int> s;
	for(int i = 0; i < n; i++) cin >> v[i];
	// 初始化
	int l = 0, r = 0;
	s.insert(v[0]);
	int ans = 1;
	while(r + 1 < n){
		r++;
		while(s.find(v[r]) != s.end()){
			int to_pop = v[l++];
			s.erase(to_pop);
		}
		s.insert(v[r]);
		ans = max(ans, (int)s.size());
	}
	cout << ans << endl;
	return 0;
}